home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / prolog / sbprolog / v3 / sim.lha / sim / inst.h < prev    next >
C/C++ Source or Header  |  1990-04-12  |  7KB  |  209 lines

  1. /************************************************************************
  2. *                                    *
  3. * The SB-Prolog System                            *
  4. * Copyright SUNY at Stony Brook, 1986; University of Arizona, 1987    *
  5. *                                    *
  6. ************************************************************************/
  7.  
  8. /*-----------------------------------------------------------------
  9. SB-Prolog is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY.  No author or distributor
  11. accepts responsibility to anyone for the consequences of using it
  12. or for whether it serves any particular purpose or works at all,
  13. unless he says so in writing.  Refer to the SB-Prolog General Public
  14. License for full details.
  15.  
  16. Everyone is granted permission to copy, modify and redistribute
  17. SB-Prolog, but only under the conditions described in the
  18. SB-Prolog General Public License.   A copy of this license is
  19. supposed to have been given to you along with SB-Prolog so you
  20. can know your rights and responsibilities.  It should be in a
  21. file named COPYING.  Among other things, the copyright notice
  22. and this notice must be preserved on all copies. 
  23. ------------------------------------------------------------------ */
  24. /* inst.h */
  25.  
  26. /* Instruction operand types  */
  27.  
  28. #define  E       0
  29. #define  P       1
  30. #define  PSS     2
  31. #define  PC      3
  32. #define  PL      4
  33. #define  PW      5
  34. #define  PA      6
  35. #define  PWW     7
  36.  
  37. #define  S       8
  38. #define  SSS     9
  39. #define  SC     10
  40. #define  SL     11
  41. #define  SW     12
  42. #define  SA     13
  43. #define  SAA    14
  44. #define  BBW    15
  45. #define  BBA    16
  46.  
  47. /* Instruction lengths  */
  48.  
  49. #define  P_LEN         4     /* opcode + pad */
  50. #define  PSS_LEN       8     /* opcode + pad + short + short */
  51. #define  PC_LEN        8     /* opcode + pad + long */
  52. #define  PL_LEN        8     /* opcode + pad + long */
  53. #define  PW_LEN        8     /* opcode + pad + long */
  54. #define  PA_LEN        8     /* opcode + pad + long */
  55. #define  PWW_LEN      12     /* opcode + pad + long + long */
  56.  
  57. #define  S_LEN         4     /* opcode + short */
  58. #define  SSS_LEN       8     /* opcode + short + short + short */
  59. #define  SC_LEN        8     /* opcode + short + long */
  60. #define  SL_LEN        8     /* opcode + short + long */
  61. #define  SW_LEN        8     /* opcode + short + long */
  62. #define  SA_LEN        8     /* opcode + short + long */
  63. #define  SAA_LEN      12     /* opcode + short + long + long */
  64. #define  BBW_LEN       8     /* opcode + byte + byte + long */
  65. #define  BBA_LEN       8     /* opcode + byte + byte + long */
  66.  
  67. struct opcode_info {
  68.    char  *name;
  69.    int    num;
  70.    int    type;
  71.    int    size;
  72. };
  73. extern  struct opcode_info  xxopcode[];
  74.  
  75. /**************************************************************************/
  76. /*    The set of instructions.                                            */
  77. /*                                                                        */
  78. /*    These are used as labels in "main.c"                                */
  79. /**************************************************************************/
  80.  
  81. /* Basic term instructions */
  82.  
  83. #define    getpvar                  0
  84. #define    getpval                  1
  85. #define    getstrv                  2
  86. #define    gettval                  3
  87. #define    getcon                   4
  88. #define    getnil                   5
  89. #define    getstr                   6
  90. #define    getlist                  7
  91. #define    unipvar                  8
  92. #define    unipval                  9
  93. #define    unitvar                 10
  94. #define    unitval                 11
  95. #define    unicon                  12
  96. #define    uninil                  13
  97. #define    getnumcon               14
  98. #define    putnumcon               15
  99. #define    putpvar                 16
  100. #define    putpval                 17
  101. #define    puttvar                 18
  102. #define    putstrv                 19
  103. #define    putcon                  20
  104. #define    putnil                  21
  105. #define    putstr                  22
  106. #define    putlist                 23
  107. #define    bldpvar                 24
  108. #define    bldpval                 25
  109. #define    bldtvar                 26
  110. #define    bldtval                 27
  111. #define    bldcon                  28
  112. #define    bldnil                  29
  113. #define    uninumcon               30
  114. #define    bldnumcon               31
  115. #define    getfloatcon             32
  116. #define    putfloatcon             33
  117. #define    unifloatcon             34
  118. #define    bldfloatcon             35
  119. #define    test_unifiable          36
  120.  
  121. #define    getlist_k               37
  122. #define    getlist_k_tvar_tvar     38
  123. #define    getlist_tvar_tvar       39
  124. #define    getcomma                40
  125. #define    getcomma_tvar_tvar      41
  126.  
  127. /* Non-determinism instructions */
  128.  
  129. #define    trymeelse               42
  130. #define    retrymeelse             43
  131. #define    trustmeelsefail         44
  132. #define    try                     45
  133. #define    retry                   46
  134. #define    trust                   47
  135. #define    getpbreg                48
  136. #define    gettbreg                49
  137. #define    putpbreg                50
  138. #define    puttbreg                51
  139.  
  140. /* Indexing instructions */
  141.  
  142. #define    switchonterm            52
  143. #define    arg                     53
  144. #define    arg0                    54
  145. #define    switchonbound           55
  146. #define    switchonlist            56
  147.  
  148. /* tag instructions */
  149.  
  150. #define    get_tag                 57
  151.  
  152. /* Numeric instructions */
  153.  
  154. #define    movreg                  58
  155. #define    negate                  59
  156. #define    and                     60
  157. #define    or                      61
  158. #define    lshiftl                 62
  159. #define    lshiftr                 63
  160. #define    addreg                  64
  161. #define    subreg                  65
  162. #define    mulreg                  66
  163. #define    divreg                  67
  164. #define    idivreg                 68
  165.  
  166. /* Unsafe term instructions  */
  167.  
  168. #define    putdval                 69
  169. #define    putuval                 70
  170.  
  171. /* Procedure instructions */
  172.  
  173. #define    call                    71
  174. #define    allocate                72
  175. #define    deallocate              73
  176. #define    proceed                 74
  177. #define    execute                 75
  178. #define    calld                   76
  179.  
  180. /* Branching instructions */
  181.  
  182. #define    jump                    77
  183. #define    jumpz                   78
  184. #define    jumpnz                  79
  185. #define    jumplt                  80
  186. #define    jumple                  81
  187. #define    jumpgt                  82
  188. #define    jumpge                  83
  189.  
  190. /* Miscellaneous instructions */
  191.  
  192. #define    fail                    84
  193. #define    noop                    85
  194. #define    halt                    86
  195. #define    builtin                 87
  196. #define    endfile                 88
  197.  
  198. #define    hash                    89
  199. #define    getival                 90
  200. #define    jumptbreg               91
  201. #define    unexec                  92
  202. #define    unexeci                 93
  203. #define    executev                94
  204.  
  205. /* virtual instruction, used for disassembler to link different segs */
  206.  
  207. extern int Switchonbound();
  208. extern int Builtin();
  209.